from idlelib.iomenu import encoding

proxies_pool = [
    {
        'http': '106.14.255.124'
    },
    {
        'http': '106.14.255.124'
    },
    {
        'http': '106.14.255.124'
    },
    {
        'http': '106.14.255.124'
    },

]

import random

proxies=random.choice(proxies_pool)

import urllib.request

url = 'http://www.baidu.com/s?wd=ip'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0',
}

request = urllib.request.Request(url=url, headers=headers)

handler=urllib.request.ProxyHandler(proxies=proxies)

opener=urllib.request.build_opener(handler)

respons=opener.open(request)

content=respons.read().decode('utf-8')

with open('daili.html','w',encoding='utf-8') as f:
